<template>
  <div class="bulletin">
    <el-form label-width="130px" @submit.native.prevent="Edit(id)">
      <el-form-item label="场馆编号">
        <el-input v-model="info.venue_id" placeholder="场馆编号" />
      </el-form-item>
      <el-form-item label="日期编号">
        <el-input v-model="info.meet_day_id" placeholder="日期编号" />
      </el-form-item>
      <el-form-item label="开始时间">
        <el-input v-model="info.start" placeholder="开始时间" />
      </el-form-item>
      <el-form-item label="结束时间">
        <el-input v-model="info.end" placeholder="结束时间" />
      </el-form-item>
      <el-form-item label="是否限制人数">
        <el-select v-model="info.is_limit">
          <el-option :value="0" label="否" />
          <el-option :value="1" label="是" />
        </el-select>
      </el-form-item>
      <el-form-item label="报名上限">
        <el-input v-model="info.limit" placeholder="报名上限" />
      </el-form-item>
      <el-form-item label="PublisherUid">
        <el-input v-model="info.publisher_uid" placeholder="PublisherUid" />
      </el-form-item>
      <el-form-item label="发布时间">
        <el-date-picker v-model="info.created_at" type="datetime" placeholder="选择发布时间" value-format="yyyy-MM-dd HH:mm:ss" />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" native-type="submit">提交</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>
<script>
import SingleImage from '@/components/Upload/SingleImage'
import Tinymce from '@/components/Tinymce'
import { parseTime } from '@/utils/index'
export default {
  components: {
    Tinymce,
    SingleImage
  },
  data() {
    return {
      id: this.$route.params.id,
      info: {},
      created_at: parseTime(new Date().getTime())
    }
  },
  mounted() {
    this.GetInfoById(this.id)
  },
  methods: {
    GetInfoById(id) {
      this.$http.get('meet_hours/' + id).then(response => {
        console.log(response)
        this.info = response.resource
      })
    },
    Edit(id) {
      const params = {
        venue_id: this.info.venue_id,
        meet_day_id: this.info.meet_day_id,
        start: this.info.start,
        end: this.info.end,
        is_limit: this.info.is_limit,
        limit: this.info.limit,
        publisher_uid: this.info.publisher_uid,
        created_at: this.info.created_at
      }
      this.$http.patch('meet_hours/' + id, params).then(response => {
        this.$success('操作成功')
        this.$router.push('meet/meet-hours')
      })
    }
  }
}
</script>

<style>
.bulletin .el-progress-circle {
  background: #fff;
}
.avatar-uploader {
  position: relative;
}
.avatar-uploader .percent {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}
.avatar-uploader .el-upload {
  border: 1px dashed #d9d9d9;
  border-radius: 6px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.avatar-uploader .el-upload:hover {
  border-color: #409eff;
}
.avatar-uploader-icon {
  font-size: 28px;
  color: #8c939d;
  width: 178px;
  height: 178px;
  line-height: 178px;
  text-align: center;
}
.avatar {
  max-width: 500px;
  display: block;
}
</style>
